
package com.skytech.tax.customsdatawarehouse.fta.origincredential.resource;


import com.skytech.tax.customsdatawarehouse.fta.origincredential.domain.service.FtaOriginCredentialFileService;
import com.skytech.tax.customsdatawarehouse.fta.origincredential.domain.service.FtaOriginCredentialService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/fta/origin-credentials")
public class FtaOriginCredentialController {

    @Resource
    private FtaOriginCredentialService ftaOriginCredentialService;
    @Resource
    private FtaOriginCredentialFileService ftaOriginCredentialFileService;

    @PostMapping
    public void saveOriginCredentials(@RequestBody String originCredentials) {
        ftaOriginCredentialService.save(originCredentials);
    }

    @GetMapping("{docId}/file")
    public String originCredentialFile(@PathVariable String docId) {
        return ftaOriginCredentialFileService.originCredentialFile(docId);
    }

    @DeleteMapping("{docId}/file")
    public void deleteOriginCredentialFile(@PathVariable String docId) {
        ftaOriginCredentialFileService.deleteOriginCredentialFile(docId);
    }

    @PostMapping("/{docId}/file")
    public void saveOriginCredentialFile(@PathVariable String docId, @RequestBody String file) {
        ftaOriginCredentialFileService.saveOriginCredentialFile(docId, file);
    }

    @GetMapping("{cusCiqNo}/file/stored")
    public boolean originCredentialFileStored(@PathVariable String cusCiqNo) {
        return ftaOriginCredentialFileService.originCredentialFileStored(cusCiqNo);
    }
}
